package com.liao.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.liao.dao.RecordDao;


import com.liao.util.Result;

@RestController
public class RecordController {
     @Autowired
     RecordDao rdao;
     @RequestMapping("/getAllRecord")
     @ResponseBody
     public Object getAllRecord(@RequestParam Map<String, Object> map) {
			 
    	 Integer page = Integer.parseInt(map.get("page").toString());
 		Integer limit = Integer.parseInt(map.get("limit").toString());
 		
 		map.put("page", (page - 1) * limit);
 		map.put("limit", limit);
 		List<Map<String, Object>>    record = rdao.getAllRecord(map);

 		int count = rdao.getCount();// 获取总条数
 		Result res = new Result("0", "true", count, record);
 		return res;
     }
   @RequestMapping("/Recorinserts")
    @ResponseBody
     public Object Recorinserts(@RequestParam Map<String, Object> map) {
   	 Result res =new Result("0","true",rdao.Recordinserts(map),"添加成功");
   	 return res;    
    }
     @RequestMapping("/Recorupdate")
     @ResponseBody
    public Object Recorupdate(@RequestParam Map<String, Object> map) {
   	 Result res =new Result("0","true",rdao.Recordupdate(map),"修改成功");
    	 return res; 
    }
     @RequestMapping("/Recordel")
     @ResponseBody
     public Object Recordel( int rid) {
    	 Result res =new Result("0","true",rdao.Recorddeletes(rid),"删除成功");
    	 return res; 
    }
}
